package com.itheima.order.service.impl;

import com.itheima.client.UserClient;
import com.itheima.order.Pojo.Order;
import com.itheima.order.mapper.OrderMapper;
import com.itheima.order.service.OrderService;
import com.itheima.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private UserClient userClient;

    @Override
    public Order getOrder(Long id) {
        Order order = orderMapper.getOrder(id);

        User user = userClient.getUser(order.getUserId());

        order.setUser(user);
        return order;
    }
}
